import request from "@/utils/request";

const urlMiddlePath = "/business/categories/";

// 创建产品分类
export function createCategoryApi(data) {
  return request({
    url: urlMiddlePath + "create",
    method: "post",
    data,
  });
}

// 查询所有产品分类
export function getCategoryListApi(params) {
  return request({
    url: urlMiddlePath + "list",
    method: "get",
    params,
  });
}

// 查询单个产品分类
export function getCategoryInfoByIdApi(id) {
  return request({
    url: urlMiddlePath + `getInfoById?id=${id}`,
    method: "get",
  });
}

// 更新产品分类
export function updateCategoryInfoByIdApi(id, data) {
  return request({
    url: urlMiddlePath + `updateInfoById?id=${id}`,
    method: "post",
    data,
  });
}

// 删除产品分类
export function deleteCategoryInfoByIdApi(id) {
  return request({
    url: urlMiddlePath + `delete?id=${id}`,
    method: "get",
  });
}

// 批量更新分类排序
export function sortCategoryInfoByIdApi(data) {
  return request({
    url: urlMiddlePath + `sort`,
    method: "post",
    data,
  });
}
